package dao;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class BaseDao {

	public Connection con;
	
	public BaseDao(){
		
		try {
			Context ctx = new InitialContext();
			DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/kioskcar");
			
			try {
				con = ds.getConnection();
			} catch (SQLException e) {
				System.out.println("Erro ao abrir conexão com o banco. "  + e.getCause() + " - " + e.getMessage());
			}
			
		  } catch (NamingException e) {
				System.out.println("Erro ao fazer o datasource. "  + e.getCause() + " - " + e.getMessage());
		  }
	}
}